import {
  Column,
  CreateDateColumn,
  Entity,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { User } from '../../user/entities/user.entity';

@Entity('sys_log')
export class Log {
  @PrimaryGeneratedColumn('uuid')
  id: string;
  @Column({ type: 'varchar', comment: '错误日志', name: 'error_data' })
  errorData: string;
  @Column({
    type: 'varchar',
    comment: '操作用户',
    name: 'user_account',
    default: null,
    length: 60,
  })
  userAccount: string;
  @Column({
    type: 'varchar',
    comment: '前端报错路由',
    name: 'router_client',
    default: null,
    length: 100,
  })
  routerClient: string;
  @Column({
    type: 'varchar',
    comment: '报错接口',
    name: 'router_service',
    default: null,
    length: 100,
  })
  routerService: string;
  @Column({
    type: 'varchar',
    name: 'request_methods',
    default: null,
    comment: '请求方法',
    length: 20,
  })
  requestMethods: string;
  @Column({
    type: 'varchar',
    comment: '客户端操作系统',
    name: 'system_client',
    default: null,
  })
  systemClient: string;
  @Column({
    type: 'varchar',
    comment: '服务器操作系统',
    name: 'system_server',
    default: null,
  })
  systemServer: string;
  @Column({
    type: 'varchar',
    comment: '客户端IP',
    length: 140,
    name: 'ip_client',
    default: null,
  })
  ipClient: string;
  @Column({ type: 'varchar', comment: '参数', default: null })
  params: string;
  @Column({ type: 'varchar', comment: '设备名称', default: null })
  model: string;
  @Column({ type: 'varchar', comment: '操作系统', default: null })
  platform: string;
  @Column({
    type: 'varchar',
    comment: '设备id',
    name: 'device_id',
    default: null,
  })
  deviceId: string;
  @Column({
    type: 'varchar',
    comment: '设备语言',
    default: null,
  })
  language: string;
  @Column({
    type: 'int',
    comment: '设备状态栏高度',
    name: 'window_top',
    default: 0,
  })
  windowTop: number;
  @Column({
    type: 'int',
    comment: '设备bar高度',
    name: 'window_bottom',
    default: 0,
  })
  windowBottom: number;
  @Column({
    type: 'int',
    comment: '设备屏幕高度',
    name: 'window_height',
    default: 0,
  })
  windowHeight: number;
  @Column({
    type: 'int',
    comment: '设备屏幕宽度',
    name: 'window_width',
    default: 0,
  })
  windowWidth: number;
  @Column({ type: 'varchar', comment: '错误代码', default: null })
  code: string;
  @Column({
    type: 'int',
    comment: '删除标记 0-未删除 1-删除',
    name: 'is_delete',
    default: 0,
  })
  isDelete: number;
  @CreateDateColumn({
    type: 'timestamp',
    name: 'create_date',
    comment: '创建时间',
  })
  createDate: Date;
  @ManyToOne((type) => User, (user) => user.log, { eager: true })
  user: User;
}
